package com.itheima.friend;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class Friend1MapperTask extends Mapper<LongWritable,Text,Text, Text> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        //A:B,C,D,F,E,O
        String line = value.toString();
        if(line!=null && !"".equals(line)){
            String[] split = line.split(":");
            String[] friends = split[1].split(",");
            for(String friend:friends){
                context.write(new Text(friend),new Text(split[0]));
            }
        }
    }
}
